import { $Platform } from "@/utils/const/env";
import { siteinfo } from "@/siteinfo";
export const info = () => uni.getSystemInfoSync();

export const isIos = () => {
	return info().osName === 'ios';
};
export const isAndroid = () => {
	return info().osName === 'android';
};
export const isWechat = () => {
	return true;
};
export const platforms = () => {
	let result: string[] = [];
	if (isIos()) {
		result.push($Platform.MP_WEIXIN_IOS);
	} else if (isAndroid()) {
		result.push($Platform.MP_WEIXIN_ANDROID);
	}
	return result;
};
export const isDev = () => process.env.NODE_ENV !== 'production';
export const isProd = () => process.env.NODE_ENV === 'production';
export const appid = () => siteinfo.app_id;
export const host = () => siteinfo.siteroot;
export const name = () => siteinfo.name;

export const chooseImage = (options: UniNamespace.ChooseImageOptions) => {
	uni.chooseImage({
		count: 1,
		sizeType: ['original'], //可以指定是原图还是压缩图，默认二者都有
		sourceType: ['album', 'camera'], //从相册选择
		...options
	});
}
export const chooseVideo=(options: UniNamespace.ChooseVideoOptions)=>{
	uni.chooseVideo({
		sourceType: ['album', 'camera'], //从相册选择
		...options
	});
}
export const scanCode = (options?: UniNamespace.ScanCodeOptions) => {
	uni.scanCode({
		onlyFromCamera: true,
		...options
	});
}
export const saveImageToPhotosAlbum = (options: UniNamespace.SaveImageToPhotosAlbumOptions) => {
	uni.saveImageToPhotosAlbum({
		...options
	});
}